package com.ls.controller;

import com.ls.dto.PositionDto;
import com.ls.service.PositionService;
import com.ls.utils.Status;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(value = "PositionController",tags = "职位管理")
public class PositionController {

    @Autowired
    private PositionService positionService;

    @ApiOperation(value = "获取所有职位信息")
    @GetMapping("/position/getList")
    public Status getList(PositionDto positionDto){
        System.out.println(positionDto);
        return positionService.getPositionsResult(positionDto);
    }

    @ApiOperation(value = "删除职位信息")
    @GetMapping("/position/delete")
    public Status delete(PositionDto positionDto){
        return positionService.deleteResult(positionDto);
    }

    @ApiOperation(value = "添加职位信息")
    @PostMapping("/position/add")
    public Status add(@RequestBody PositionDto positionDto){

        System.out.println(positionDto);

        return positionService.addResult(positionDto);
    }

    @ApiOperation(value = "/修改职位信息")
    @PostMapping("/position/update")
    public Status getPositionService(@RequestBody PositionDto positionDto) {
        return positionService.updateResult(positionDto);
    }

    @ApiOperation(value = "修改职位状态")
    @PostMapping("/position/updStatus")
    public Status updStatus(@RequestBody PositionDto positionDto){
        System.out.println(positionDto);
        return positionService.updStatusResult(positionDto);
    }

    @ApiOperation(value = "职位名称是否重复")
    @GetMapping("/position/isRepeat")
    public Status checkRepeatName(PositionDto positionDto){
        return positionService.isRepeatResult(positionDto);
    }

    @ApiOperation("获取单个职位信息")
    @GetMapping("/position/get")
    public Status getPosition(PositionDto positionDto){
        return positionService.getPositionsResult(positionDto);
    }
}
